from selenium.webdriver.common.by import By
import time
from unit__003.unit_06.base import Base

class Page_login(Base):
    # 页面元素定位

    # 1.点击登录
    login_loc=(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a')
    # 2.输入账号
    username_loc=(By.NAME,'username')
    # 3.输入密码
    password_loc=(By.XPATH,'//*[@id="theForm"]/div[2]/span[2]/input')
    # 4.点击登录 class="finish-btn"
    loginbtn_loc=(By.CLASS_NAME,'finish-btn')

    # 封装元素的操作方法
    # 1.点击登录
    def login(self):
        self.click(self.login_loc)
    # 2.输入账号
    def sr_username(self,username):
        self.send_keys(self.username_loc,username)
    # 3.输入密码
    def sr_password(self,password):
        self.send_keys(self.password_loc,password)
    # 4.点击登录
    def loginbtn(self):
        self.click(self.loginbtn_loc)

    # A3mall登录逻辑
    def A3mall_login_luoji(self):
        self.open_url('http://10.59.9.14:7003/home/index.html')
        time.sleep(3)
        # 1.点击登录
        self.login()
        time.sleep(2)
        # # 断言1-会员登录
        # dy1 = self.driver.find_element(By.CLASS_NAME, 'reg-new').text
        # print('断言1：', dy1)
        # self.assertEqual('会员登录', dy1)
        time.sleep(2)
        # 2.输入账号
        self.sr_username('18185603008')
        time.sleep(2)
        # 3.输入密码
        self.sr_password('123456')
        time.sleep(10)
        # 4.点击登录
        self.loginbtn()
        time.sleep(5)


